Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
What is the definition of "scope" when we are talking about function hoisting in JavaScript

I am learning JavaScript Function Hoisting, which says "the declaration of functions are moved to the top of their scope". Then I read the definition of "scope" from this doc, it says "A function serves as a closure in JavaScript, and thus creates a scope". So does it mean any functions declared inside a function are moved to the top of that function? I use the following example to test:

foo();

function foo() {
   console.log(too);
   console.log(zoo);
   {
      function too() {console.log("too");}
   }
   function zoo() {console.log("zoo");}
}

The out put is

undefined
ƒ zoo() {console.log("zoo");}

So obviously the declaration of too is not moved to the top of foo. It is actually moved to the top of the block statement inside foo. So what is the exact definition of "scope" when we are talking about function hoisting in JavaScript?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!